<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class tarifa_x_diaM extends CI_Model {

    public function __construct() {
        $this->load->database();
    }

    public function insertarRegistro($idrReserva, $idCuarto, $dia, $precio) {
        $query = "INSERT INTO tarifa_x_dia values('$idrReserva','$idCuarto','$dia','$precio')";
        //   echo "<br>".$query;
        return $this->db->query($query);
    }

    public function obtenerTarifasPorReserva($idReserva) {
        $query = "SELECT * from tarifa_x_dia where id_reserva='$idReserva'";
        return $this->db->query($query)->result();
    }

    public function eliminarRegistros($idReserva, $idHabitacion) {
        $query = "DELETE from tarifa_x_dia where id_reserva='$idReserva' AND id_cuarto='$idHabitacion'";
        return $this->db->query($query);
    }

    public function obtenerCostosHospedaje($idReserva) {
        $query = "SELECT  COALESCE(SUM(precio),0) totalHospedaje from tarifa_x_dia WHERE id_reserva='$idReserva'";
        return $this->db->query($query)->result();
    }

}
